package online.westonline.com.westonline.wedgit;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import online.westonline.com.westonline.R;

/**
 * 旋转停不下来的那种图片(刷新)
 * Created by xiatao on 2018/8/29.
 */

public class RomateImageView extends ImageView
{
    private boolean start=false;
    private Animation refreshAnimation;
    public RomateImageView(Context context) {
        super(context);
    }

    public RomateImageView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public RomateImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public boolean isStart() {
        return start;
    }

    public void show(boolean start)
    {
        this.start = start;
        animateStart();
    }
    /***
     * 动画开始
     */
    private void animateStart() {
            //不重置
            //转圈开始
            if (start)
            {
                refreshAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.rotaot_anmation);
                //refreshAnimation.reset();
                this.clearAnimation();
                this.startAnimation(refreshAnimation);
            }
            else
            {
                //不重置
                //refreshAnimation.reset();
                this.clearAnimation();
            }


    }
}
